
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
#include <vector>


#include "Loader.h"
#include "LoaderAnim.h"
#include "MainLoader.h"
#include "Anim.h"
#include "Anim_Pack.h"
#include "AnimMorph.h"
#include "Graphic_Module.h"

int main()
{

    MainLoader Data;
    Data.AddLoader("monster_spell_anim.png");
    Data.AddLoader("monster_idle_anim.png");
    Data.AddLoader("monster_move_anim.png");
    Data.AddLoader("monsterB_spell_anim.png");
    Data.AddLoader("monsterB_idle_anim.png");
    Data.AddLoader("monsterB_move_anim.png");
    //std::vector<sf::Sprite> test = (Data.GetLoader())[0].GetData();

    std::vector<int> V1,V2,V3,V4;
    for(int i=0;i<8;i++){
        V1.push_back(6);
        }
    for(int i=0;i<3;i++){
        V2.push_back(6);
        }
    for(int i=0;i<4;i++){
        V3.push_back(6);
        }
    for(int i=0;i<7;i++){
        V4.push_back(6);
        }
    Anim Golem_spell_A("spell","monster_spell_anim",8,&Data,V1, true,true);
    Anim Golem_idle_A("idle","monster_idle_anim",3,&Data,V2, true,false);
    Anim Golem_move_A("move","monster_move_anim",4,&Data,V3, true,false);

    Anim_Pack Golem_A("golem_A","idle");
    Golem_A.AddAnim(Golem_idle_A);
    Golem_A.AddAnim(Golem_move_A);
    Golem_A.AddAnim(Golem_spell_A);

    Anim Golem_spell_B("spell","monsterB_spell_anim",7,&Data,V4, true,true);
    Anim Golem_idle_B("idle","monsterB_idle_anim",3,&Data,V2, true,false);
    Anim Golem_move_B("move","monsterB_move_anim",4,&Data,V3, true,false);

    Anim_Pack Golem_B("golem_B","idle");
    Golem_B.AddAnim(Golem_idle_B);
    Golem_B.AddAnim(Golem_move_B);
    Golem_B.AddAnim(Golem_spell_B);

    AnimMorph Golem ("Golem","idle","golem_A");
    Golem.AddAnim_Pack(Golem_A);
    Golem.AddAnim_Pack(Golem_B);

    Coord c(100,100);
    Camera cam(c);
    MainGraphic MG(cam);


    Graphic_Module GM_test(Golem,"idle","golem_A",MG);


    //Data.Draw();
    // Create the main window


    int timer=0;
	// Start the game loop

    while (MG.IsOpened())
    {

        // Process events
        sf::Event Event;
        while (MG.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                MG.Close();
        }

        // Clear screen
        MG.Clear();
        timer++;
        if (timer==150){
                Golem.Send_Statut("move");
                std::cout<<std::endl<<"hello, i'm moving"<<Golem.GetStatut();
        }
        if (timer==210){
                Golem.Send_Statut("spell");
                Golem.Send_Morphe("golem_B");
        }
        if (timer==240){
                Golem.Send_Statut("move");
        }


        // Draw the sprite


        MG.Draw(Golem.GetSprite(),c);
        //App.Draw(test[2]);
        //App.Draw(V_temp[2]);


        // Update the window
        MG.Display();

    }

    return EXIT_SUCCESS;
}
